perm filename CON.DIF[CLS,LSP] blob sn#827062 filedate 1986-10-27 generic text, type T, neo UTF8
  1) CONCEP.1[CLS,LSP] and 2) CONCEP.2[CLS,LSP]	10-27-86 18:03	pages 1,1

**** File 1) CONCEP.1[CLS,LSP]/1P/22L
1)	This chapter describes the standard user interface for object-oriented
1)	programming in the \CLOS.  The chapter ``Meta-Object
1)	Protocol'' describes how the \CLOS\  can be customized to accommodate
1)	existing object-oriented paradigms and to define new ones.
1)	\vfill
1)	\endSection%{Introduction}
1)	\beginSection{Objects and Classes}
1)	Under this proposal, the primitive entities of Common Lisp are called
1)	{\bit objects}.  Every Common Lisp data structure is an object that
1)	is an {\bit instance\/} of a unique class.
1)	A {\bit class\/} determines the structure and behavior of a set of
1)	objects, called its {\bit instances}.  The class of an object
1)	indirectly determines the set of operations into which the object can
1)	enter.  It is an important feature of the \OS\ that all Lisp data
1)	structures have a determinable class.
1)	A class is itself an object.
1)	Like other objects, all classes are themselves instances of other classes.
**** File 2) CONCEP.2[CLS,LSP]/1P/22L
2)	This proposal presents a description of the standard user
2)	interface for object-oriented programming in the \CLOS.  A second
2)	document, ``The \CLOS\ Meta-Object Protocol'' describes how the
2)	\CLOS\ can be customized to accommodate existing object-oriented
2)	paradigms and to define new ones.
2)	Under this proposal, the primitive entities of Common Lisp are called
2)	{\bit objects}.  The fundamental objects of the \CLOS\ are
2)	classes, generic function objects, and method objects.  [What is
2)	the ontological status of method combination?]  [Meta-objects?]
2)	A {\bit class\/} object determines the structure and behavior of a set
2)	of other objects, called its {\bit instances}.  The class of an object
2)	indirectly determines the set of operations into which the object can
2)	enter.  It is an important feature of the \OS\ that every Common Lisp
2)	data structure is an object that is an {\bit instance\/} of a unique
2)	class.
2)	{\bit Generic functions} are objects that may be specialized to
2)	provide class-specific operations.  A generic function is a function
2)	that is able to designate one of a set of possible operations based on
2)	the classes of its arguments.  A generic function can be used as an
2)	argument to {\bf funcall} and {\bf apply} and stored in the
2)	symbol-function cell of a symbol.
2)	The class-specific operations provided by generic functions are
2)	themselves defined and implemented by {\bit methods}.  A method is
2)	also a function object.  The method object contains a method function
2)	and a set of {\bit argument specializers\/} that specify when the
2)	given method is applicable.
2)	%  A method can be used as an argument to
2)	%  {\bf funcall} and {\bf apply} and stored in the symbol-function cell
2)	%  of a symbol.  [This needs to be decided.]
  1) CONCEP.1[CLS,LSP] and 2) CONCEP.2[CLS,LSP]	10-27-86 18:03	pages 1,1

2)	When a generic function is invoked, the selection and sequencing of
2)	the individual methods that are applicable may be further controlled by the
2)	{\bit method combination\/} facility.   Method combination qualifiers,
2)	types, and rules [or what do we call these?] can be used to precisely
2)	define which methods are invoked when a given generic function is called
2)	with specific classes of arguments.
2)	\vfill
2)	\endSection%{Introduction}
2)	\beginSection{Classes}
2)	A {\bit class\/} is an object that determines the structure and behavior
2)	of a set of other objects, called its {\bit instances}.
2)	Like other objects, all classes are themselves instances of other classes.
***************


**** File 1) CONCEP.1[CLS,LSP]/1P/78L
1)	\Vskip 1pc!
**** File 2) CONCEP.2[CLS,LSP]/1P/109L
2)	\vfill\eject
2)	\Vskip 1pc!
***************


**** File 1) CONCEP.1[CLS,LSP]/1P/110L
1)	The syntax for {\bf defclass} is given in Figure~1-3.
1)	The new class created by {\bf defclass} is a subclass of all the
**** File 2) CONCEP.2[CLS,LSP]/1P/143L
2)	The syntax for {\bf defclass} is given in Figure}1-3.
2)	The new class created by {\bf defclass} is a subclass of all the
***************


**** File 1) CONCEP.1[CLS,LSP]/1P/139L
1)	\vfill\eject
1)	\beginsubSection{Accessing Slots}
**** File 2) CONCEP.2[CLS,LSP]/1P/173L
2)	\beginsubSection{The Structure of Class Objects}
2)	\endsubSection%{The Structure of Class Objects}
2)	\beginsubSection{Creating Instances of Classes}
2)	\endsubSection%{Creating Instances of Classes}
2)	\beginsubSection{Superclasses}
2)	\endsubSection%{Superclasses}
2)	\beginsubSection{Inheritance}
2)	\endsubSection%{Inheritance}
2)	\beginsubSection{Class Precedence}
2)	%brief introduction to notion of class precedence
2)	\endsubSection%{Class Precedence}
2)	\beginsubSection{Accessing Slots}
  1) CONCEP.1[CLS,LSP] and 2) CONCEP.2[CLS,LSP]	10-27-86 18:03	pages 1,1

***************


**** File 1) CONCEP.1[CLS,LSP]/1P/157L
1)	\endSection%{Objects and Classes}
1)	\beginSection{Generic Functions}
1)	A {\bit generic function\/} is a function object, which, when it is invoked,
1)	is able to designate one out of a set of operations, depending on the
1)	classes of its arguments.  The generic function is said to
1)	{\bit discriminate\/} on the classes of its arguments.
1)	[The following is under discussion:
1)	A generic function is a first-class object in the \CLOS.
1)	It can be used as an argument to {\bf funcall} or {\bf apply} and
1)	stored in the symbol-function cell of a symbol.]
1)	[The following is under discussion:  A generic function is created
1)	using the function {\bf make-generic} or the
1)	macro {\bf defgeneric}. The macro {\bf defgeneric} stores the generic function
1)	in a specified symbol-function cell.]
1)	The operations that are provided by a generic function are defined by
1)	the methods associated with it.
1)	A {\bit method\/} is a function object.  It consists of two
1)	parts: a set of argument
1)	specifiers that is used to determine when it is applicable and a method
1)	function.
1)	%Methods are first-class objects in the \CLOS.
1)	A method can be used as an argument to {\bf funcall} or {\bf apply} and
1)	stored in the symbol-function cell of a symbol.
1)	A method can be defined and associated
1)	with a generic function by using {\bf defmethod} or {\bf add-method}.
1)	[An issue under discussion is whether a generic function must be defined
1)	before any methods can be added to it.]
1)	When a generic function is invoked, the arguments specifiers of its
1)	associated methods are used to determine which method function is
1)	invoked.
1)	An {\bit argument specifier} is the name of a class or an
1)	individual.
1)	The class of each of the arguments passed to the generic function
1)	is determined and the classes of the arguments are then
1)	compared with the
1)	argument specifiers of each of the methods associated with the generic
1)	function.  The method function of the method with the most specific
1)	set of argument specifiers that are identical to or more general than
1)	the classes of the arguments is invoked.  The order in which differences
1)	between the classes of the arguments and the arguments specifiers are
1)	considered is defined by the
1)	{\bit argument precedence order\/} for the generic function. The relative
1)	specificity of argument specifiers is determined by the class lattice.
1)	%The {\bf class precedence list} is used to determine
  1) CONCEP.1[CLS,LSP] and 2) CONCEP.2[CLS,LSP]	10-27-86 18:03	pages 1,1

1)	%which specifier is more specific.
1)	Any individual is always more specific than any class.  There
1)	is a class named {\bf t} that is more general than any other class.  When every
1)	argument specifier in the set of argument specifiers for a method is either
1)	unspecified or {\bf t}, the method function for that method is called the
1)	{\bit default method function\/} of the generic function.
1)	%The precise definition for determining which method of a generic
1)	%function to invoke will be given in section XXX.
1)	\endsubSection
1)	\endSection%{Generic Functions}
1)	\beginSection{Method Combination}
1)	[To be written.]
1)	We are currently working to integrate the programmatic ({\bf
1)	run-super}) and declarative ({\bf define-method-combination}) method
1)	combination techniques.  The references to method combination throughout
1)	this document will be further specified in a future draft.
1)	%Methods can be combined by means of the {\bf run-super} construct.
1)	%The {\bf run-super} construct allows a method to specialize a ``super''
1)	%method.
1)	\endSection%{Method Combination}
1)	\beginSection{Metaclasses}
1)	The {\bit metaclass\/} of an object is the class of its class.  The metaclass
1)	determines the form of inheritance used by its classes and
1)	the representation of the instances of its classes.  The metaclass mechanism
1)	can be used to provide particular forms of optimization or to tailor
1)	the \OS\  for particular uses (such as the implementation of other
1)	object languages---like Flavors, Smalltalk-80, and Loops).
1)	Any new metaclass must define the structure of its instances, how their storage
1)	is allocated, how their slots are accessed, and how slots and methods are
1)	inherited.  The protocol for defining
1)	metaclasses will be discussed in the chapter ``Meta-Object Protocol.''
1)	\beginsubSection{Standard Metaclasses}
1)	The \OS\  defines a number of {\bit standard metaclasses}.  These include
1)	the following:
1)	{\bf standard-type-class}, {\bf structure-class}, and {\bf class}.
1)	The class {\bf standard-type-class} is a superclass of all the classes
1)	that correspond to the standard Common Lisp types specified in
1)	{\it Common Lisp: The Language\/} by Guy L. Steele Jr. except {\bf atom} and
1)	{\bf common}.  These types are listed in Figure~1-1.
1)	This metaclass allows the special kind of class
1)	inheritance rules that are needed to handle the classes that 
1)	correspond to the standard Common Lisp types.
1)	It is not possible to make an instance
1)	of a class whose class is {\bf standard-type-class} using the function
1)	{\bf make-instance}.  
1)	%It is possible to define methods for built-in classes.
1)	The class {\bf structure-class} is a subclass of {\bf standard-type-class}.  
1)	All classes defined by means of {\bf defstruct} are instances or
  1) CONCEP.1[CLS,LSP] and 2) CONCEP.2[CLS,LSP]	10-27-86 18:03	pages 1,1

1)	{\bf structure-class} or a subclass of {\bf structure-class}.
1)	%The use of {\bf defstruct} implicitly defines a new class which is an
1)	%instance of {\bf structure-class}.
1)	%Instances of {\bf primitive-lisp-type-class} are classes that correspond
1)	%to the basic Common Lisp types.  
1)	%While all classes that correspond to the types
1)	%listed in Figure~1-1 must be instances of either {\bf structure-class}
1)	%or {\bf primitive-lisp-type-class}, no implementation is {\it required\/} to
1)	%have any class that is an instance of {\bf primitive-lisp-type-class}.
1)	\endsubSection
1)	\beginsubSection{Integrating Types and Classes}
1)	The \OS\  maps the Common Lisp type space into the space
1)	of classes.  
1)	Figure~1-2 displays part of the lattice of classes that are instances of
1)	a subclass of {\bf standard-type-class}.
**** File 2) CONCEP.2[CLS,LSP]/1P/210L
2)	\beginsubSection{Types and Classes}
2)	The \OS\  maps the Common Lisp type space into the space
2)	of classes.  
2)	Figure}1-2 displays part of the lattice of classes that are instances of
2)	a subclass of {\bf standard-type-class}.
***************


**** File 1) CONCEP.1[CLS,LSP]/1P/311L
1)	\eject
1)	The classes {\bf number}, {\bf integer}, {\bf rational}, {\bf float},
**** File 2) CONCEP.2[CLS,LSP]/1P/231L
2)	The classes {\bf number}, {\bf integer}, {\bf rational}, {\bf float},
***************


**** File 1) CONCEP.1[CLS,LSP]/1P/327L
1)	\font \foofont = cmr10 at 1sp
1)	\IgnoreWhiteSpace
**** File 2) CONCEP.2[CLS,LSP]/1P/246L
2)	\font \foofont = amr10 at 1sp
2)	\IgnoreWhiteSpace
***************


**** File 1) CONCEP.1[CLS,LSP]/6P/52L
1)	\endSection
**** File 2) CONCEP.2[CLS,LSP]/1P/504L
2)	\endsubSection%{Types and Classes}
2)	\endSection%{Classes}
2)	\beginSection{Generic Functions and Methods}
2)	A {\bit generic function\/} is a function object, which, when it is invoked,
  1) CONCEP.1[CLS,LSP] and 2) CONCEP.2[CLS,LSP]	10-27-86 18:03	pages 6,1

2)	is able to designate one out of a set of operations, depending on the
2)	classes of its arguments.  The generic function is said to
2)	{\bit discriminate\/} on the classes of its arguments.
2)	[The following is under discussion:
2)	A generic function is a first-class object in the \CLOS.
2)	It can be used as an argument to {\bf funcall} or {\bf apply} and
2)	stored in the symbol-function cell of a symbol.]
2)	[The following is under discussion:  A generic function is created
2)	using the function {\bf make-generic} or the
2)	macro {\bf defgeneric}. The macro {\bf defgeneric} stores the generic function
2)	in a specified symbol-function cell.]
2)	The operations that are provided by a generic function are defined by
2)	the methods associated with it.
2)	A {\bit method\/} is a function object.  It consists of two
2)	parts: a set of argument
2)	{\bit specializers\/} that is used to determine when it is applicable and a method
2)	function.
2)	%Methods are first-class objects in the \CLOS.
2)	A method can be used as an argument to {\bf funcall} or {\bf apply} and
2)	stored in the symbol-function cell of a symbol.
2)	A method can be defined and associated
2)	with a generic function by using {\bf defmethod} or {\bf add-method}.
2)	[An issue under discussion is whether a generic function must be defined
2)	before any methods can be added to it.]
2)	When a generic function is invoked, the arguments specializers of its
2)	associated methods are used to determine which method function is
2)	invoked.
2)	An {\bit argument specializer\/} is the name of a class or an
2)	individual.
2)	The class of each of the arguments passed to the generic function
2)	is determined and the classes of the arguments are then
2)	compared with the
2)	argument specializers of each of the methods associated with the generic
2)	function.  The method function of the method with the most specific
2)	set of argument specializers that are identical to or more general than
2)	the classes of the arguments is invoked.  The order in which differences
2)	between the classes of the arguments and the arguments specializers are
2)	considered is defined by the
2)	{\bit argument precedence order\/} for the generic function. The relative
2)	specificity of argument specializers is determined by the class lattice.
2)	%The {\bf class precedence list} is used to determine
2)	%which specializer is more specific.
2)	Any individual is always more specific than any class.  There
2)	is a class named {\bf t} that is more general than any other class.  When every
2)	argument specializer in the set of argument specializers for a method is either
2)	unspecified or {\bf t}, the method function for that method is called the
2)	{\bit default method function\/} of the generic function.
2)	%The precise definition for determining which method of a generic
  1) CONCEP.1[CLS,LSP] and 2) CONCEP.2[CLS,LSP]	10-27-86 18:03	pages 6,1

2)	%function to invoke will be given in section XXX.
2)	\endSection%{Generic Functions and Methods}
2)	\beginSection{Method Selection}
2)	\endSection%{Method Selection}
2)	\beginSection{Method Combination}
2)	[To be written.]
2)	We are currently working to integrate the programmatic ({\bf
2)	run-super}) and declarative ({\bf define-method-combination}) method
2)	combination techniques.  The references to method combination throughout
2)	this document will be further specified in a future draft.
2)	%Methods can be combined by means of the {\bf run-super} construct.
2)	%The {\bf run-super} construct allows a method to specialize a ``super''
2)	%method.
2)	\endSection%{Method Combination}
2)	\beginSection{Meta Objects}
2)	\beginsubSection{Metaclasses}
2)	The {\bit metaclass\/} of an object is the class of its class.  The metaclass
2)	determines the form of inheritance used by its classes and
2)	the representation of the instances of its classes.  The metaclass mechanism
2)	can be used to provide particular forms of optimization or to tailor
2)	the \OS\  for particular uses (such as the implementation of other
2)	object languages---like Flavors, Smalltalk-80, and Loops).
2)	Any new metaclass must define the structure of its instances, how their storage
2)	is allocated, how their slots are accessed, and how slots and methods are
2)	inherited.  The protocol for defining
2)	metaclasses will be discussed in the chapter ``Meta-Object Protocol.''
2)	\endsubSection
2)	\beginsubSection{Standard Metaclasses}
2)	The \OS\  defines a number of {\bit standard metaclasses}.  These include
2)	the following:
2)	{\bf standard-type-class}, {\bf structure-class}, and {\bf class}.
2)	The class {\bf standard-type-class} is a superclass of all the classes
2)	that correspond to the standard Common Lisp types specified in
2)	{\it Common Lisp: The Language\/} by Guy L. Steele Jr. except {\bf atom} and
2)	{\bf common}.  These types are listed in Figure}1-1.
2)	This metaclass allows the special kind of class
2)	inheritance rules that are needed to handle the classes that 
2)	correspond to the standard Common Lisp types.
2)	It is not possible to make an instance
2)	of a class whose class is {\bf standard-type-class} using the function
2)	{\bf make-instance}.  
2)	%It is possible to define methods for built-in classes.
2)	The class {\bf structure-class} is a subclass of {\bf standard-type-class}.  
2)	All classes defined by means of {\bf defstruct} are instances or
2)	{\bf structure-class} or a subclass of {\bf structure-class}.
2)	%The use of {\bf defstruct} implicitly defines a new class which is an
2)	%instance of {\bf structure-class}.
2)	%Instances of {\bf primitive-lisp-type-class} are classes that correspond
  1) CONCEP.1[CLS,LSP] and 2) CONCEP.2[CLS,LSP]	10-27-86 18:03	pages 6,1

2)	%to the basic Common Lisp types.  
2)	%While all classes that correspond to the types
2)	%listed in Figure}1-1 must be instances of either {\bf structure-class}
2)	%or {\bf primitive-lisp-type-class}, no implementation is {\it required\/} to
2)	%have any class that is an instance of {\bf primitive-lisp-type-class}.
2)	\endsubSection
2)	\endSection
***************